/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.agenda.model.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Ronildo
 */
@Entity
@Table(name = "AM_TB_CONV_MEDI")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "AmTbConvMedi.findAll", query = "SELECT a FROM AmTbConvMedi a"),
    @NamedQuery(name = "AmTbConvMedi.findByCdConvMedi", query = "SELECT a FROM AmTbConvMedi a WHERE a.cdConvMedi = :cdConvMedi"),
    @NamedQuery(name = "AmTbConvMedi.findByNmConvMedi", query = "SELECT a FROM AmTbConvMedi a WHERE a.nmConvMedi = :nmConvMedi")})
public class AmTbConvMedi implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @Basic(optional = false)
    @Column(name = "CD_CONV_MEDI")
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "seq_AM_TB_CONV_MEDI")
    @SequenceGenerator(name="seq_AM_TB_CONV_MEDI", sequenceName = "seq_AM_TB_CONV_MEDI")
    private Short cdConvMedi;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 40)
    @Column(name = "NM_CONV_MEDI")
    private String nmConvMedi;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "cdConvMedi")
    private Collection<AmTbPlanSaud> amTbPlanSaudCollection;

    public AmTbConvMedi() {
    }

    public AmTbConvMedi(Short cdConvMedi) {
        this.cdConvMedi = cdConvMedi;
    }

    public AmTbConvMedi(Short cdConvMedi, String nmConvMedi) {
        this.cdConvMedi = cdConvMedi;
        this.nmConvMedi = nmConvMedi;
    }

    public Short getCdConvMedi() {
        return cdConvMedi;
    }

    public void setCdConvMedi(Short cdConvMedi) {
        this.cdConvMedi = cdConvMedi;
    }

    public String getNmConvMedi() {
        return nmConvMedi;
    }

    public void setNmConvMedi(String nmConvMedi) {
        this.nmConvMedi = nmConvMedi;
    }

    @XmlTransient
    public Collection<AmTbPlanSaud> getAmTbPlanSaudCollection() {
        return amTbPlanSaudCollection;
    }

    public void setAmTbPlanSaudCollection(Collection<AmTbPlanSaud> amTbPlanSaudCollection) {
        this.amTbPlanSaudCollection = amTbPlanSaudCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cdConvMedi != null ? cdConvMedi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AmTbConvMedi)) {
            return false;
        }
        AmTbConvMedi other = (AmTbConvMedi) object;
        if ((this.cdConvMedi == null && other.cdConvMedi != null) || (this.cdConvMedi != null && !this.cdConvMedi.equals(other.cdConvMedi))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.agenda.model.entity.AmTbConvMedi[ cdConvMedi=" + cdConvMedi + " ]";
    }
    
}
